//app.js


var accss_token = 'test'
var client_id = 'test'
var nonce = 'test'
var sign = 'test'
var timestamp = 'test'

  App({

    onLaunch: function () {
      //调用API从本地缓存中获取数据
      var logs = wx.getStorageSync('logs') || []
      logs.unshift(Date.now())
      wx.setStorageSync('logs', logs)
    },

    getUserInfo: function (cb) {
      var that = this
      if (this.globalData.userInfo) {
        typeof cb == "function" && cb(this.globalData.userInfo)
      } else {
        //调用登录接口
        wx.login({
          success: function () {
            wx.getUserInfo({
              success: function (res) {
                that.globalData.userInfo = res.userInfo
                typeof cb == "function" && cb(that.globalData.userInfo)
              }
            })
          }
        })
      }
    },

    globalData: {
      userInfo: null,
      searchUrl: getHostUrl() + '/mwellness-open/api/mini/search/test',
      bloodGlucoseUrl: getHostUrl() + '/mwellness-open/api/mini/user/test/bloodglucose',
      bloodGlucoseLatestUrl: getHostUrl() + '/mwellness-open/api/mini/user/test/bloodglucose/latest',
      dietLatest: getHostUrl() + '/mwellness-open/api/mini/user/test/diet/latest',
      selecDataUrlCommit: 'https://szmoka.xhwxpos.com/BookCms/public/index.php/api/book/room?step=2'
    }


  })

function getHostUrl() {
  return "http://mediaminiprogram.enjoysoho.com";
}

